namespace BB.Apostas.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class v5 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Jogoes", "Competicao_Id", "dbo.Competicaos");
            DropForeignKey("dbo.Jogoes", "Jornada_Id", "dbo.Jornadas");
            DropForeignKey("dbo.Jornadas", "Competicao_Id", "dbo.Competicaos");
            DropIndex("dbo.Jogoes", new[] { "Competicao_Id" });
            DropIndex("dbo.Jogoes", new[] { "Jornada_Id" });
            DropIndex("dbo.Jornadas", new[] { "Competicao_Id" });
            RenameColumn(table: "dbo.Jogoes", name: "Competicao_Id", newName: "CompeticaoId");
            RenameColumn(table: "dbo.Jogoes", name: "Jornada_Id", newName: "JornadaId");
            RenameColumn(table: "dbo.Jornadas", name: "Competicao_Id", newName: "CompeticaoId");
            AddForeignKey("dbo.Jogoes", "CompeticaoId", "dbo.Competicaos", "Id", cascadeDelete: true);
            AddForeignKey("dbo.Jogoes", "JornadaId", "dbo.Jornadas", "Id", cascadeDelete: true);
            AddForeignKey("dbo.Jornadas", "CompeticaoId", "dbo.Competicaos", "Id", cascadeDelete: false);
            CreateIndex("dbo.Jogoes", "CompeticaoId");
            CreateIndex("dbo.Jogoes", "JornadaId");
            CreateIndex("dbo.Jornadas", "CompeticaoId");
        }
        
        public override void Down()
        {
            DropIndex("dbo.Jornadas", new[] { "CompeticaoId" });
            DropIndex("dbo.Jogoes", new[] { "JornadaId" });
            DropIndex("dbo.Jogoes", new[] { "CompeticaoId" });
            DropForeignKey("dbo.Jornadas", "CompeticaoId", "dbo.Competicaos");
            DropForeignKey("dbo.Jogoes", "JornadaId", "dbo.Jornadas");
            DropForeignKey("dbo.Jogoes", "CompeticaoId", "dbo.Competicaos");
            RenameColumn(table: "dbo.Jornadas", name: "CompeticaoId", newName: "Competicao_Id");
            RenameColumn(table: "dbo.Jogoes", name: "JornadaId", newName: "Jornada_Id");
            RenameColumn(table: "dbo.Jogoes", name: "CompeticaoId", newName: "Competicao_Id");
            CreateIndex("dbo.Jornadas", "Competicao_Id");
            CreateIndex("dbo.Jogoes", "Jornada_Id");
            CreateIndex("dbo.Jogoes", "Competicao_Id");
            AddForeignKey("dbo.Jornadas", "Competicao_Id", "dbo.Competicaos", "Id");
            AddForeignKey("dbo.Jogoes", "Jornada_Id", "dbo.Jornadas", "Id");
            AddForeignKey("dbo.Jogoes", "Competicao_Id", "dbo.Competicaos", "Id");
        }
    }
}
